package com.moorror.codegenvel.common.select;

import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ex.CustomComponentAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.ui.components.JBTextField;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * @Author jiyanghuang
 * @Date 2024/4/11 23:15
 */
public class MRInputText extends AnAction implements CustomComponentAction, DumbAware {

    private JTextField textFileName;

    public MRInputText(int columns, String toolTipText) {
        super("Template Name", "Template Name", AllIcons.General.Settings);
        textFileName = new JBTextField();
        textFileName.setToolTipText(toolTipText);
        textFileName.setColumns(columns);
    }

    @Override
    public @NotNull JComponent createCustomComponent(@NotNull Presentation presentation, @NotNull String place) {
        return textFileName;
    }

    @Override
    public void actionPerformed(@NotNull AnActionEvent e) {
        System.out.println("--run-->");
    }

    public void fillContent(String content){
        textFileName.setText(content);
    }

    public String fetchContent(){
        return textFileName.getText();
    }
}

